package com.scl.springtalis.controller;

import com.scl.springtalis.polo.Dept;
import com.scl.springtalis.polo.Emp;
import com.scl.springtalis.polo.Result;
import com.scl.springtalis.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/depts")
public class DeptController {
//    @RequestMapping(value = "/depts",method = RequestMethod.GET)
    @Autowired
    private DeptService deptService;

    @GetMapping
    public Result List(){
        log.info("查询全部数据");
        List<Dept> List=deptService.list();
        return Result.success(List);

    }
    @DeleteMapping("/{id}")
    public Result Delete(@PathVariable int id){
        log.info("删除信息:{}",id);
        deptService.Delete(id);
        return Result.success();
    }
    @PostMapping
    public Result Insert(@RequestBody Dept dept){
        log.info("新增数据:{}",dept);
        deptService.Add(dept);
        return Result.success();


    }
}
